<template lang="html">
  <div class="record">
    <div class="withdrawal">
      <div class="container">
    <scroll
      class="scroll"
      :data="drawalList"
      :pullup="isPullup"
      @scrollToEnd="searchMore"
      v-if="drawalList && drawalList.length"
      ref="suggest"
    >
    <ul>
      <li v-for="item in drawalList">
        <div class="info">
          <div class="text">
            {{ item.goods_type }}
          </div>
          <div class="date">
            {{ item.add_time }}
          </div>
        </div>
        <div class="num">
          -{{ item.order_price }}
        </div>
      </li>
    </ul>
    </scroll>

    <div
      class="notMore flex-display flex-display-column flex-center-align"
      v-if="isLoading && !drawalList.length"
    >
      <img src="/static/ethel_img/shopping_img_em.png">
      <span>记录空空如也！！</span>
    </div>
  </div>
  </div>
  </div>
</template>

<script>
import { getJifenInfo } from '@/api/checkin'

import Scroll from "@/base/scroll/scroll";
import Loading from "@/base/loading/loading";
import { Toast, MessageBox, Indicator } from "mint-ui";
export default {
  data() {
    return {
      isHasMore: true, // 是否需要上拉加载
      drawalList: [], // 列表数据
      isPullup: true, // 是否需要监听下拉加载
      isNext: "", // 是否有下一页
      isLoading: false,
    }
  },
  created() {
    document.title = '兑换记录'
    this.getJifenInfo();
  },
  methods: {
    getJifenInfo() {
      Indicator.open({
        text: "加载中...",
        spinnerType: "fading-circle"
      });
      getJifenInfo({
        uid: this.getUserInfo().id,
        isNext: this.isNext ? this.isNext : ""
      }).then(res=>{
        console.log(res)
        Indicator.close();
        this.isLoading = true;
        this.drawalList = [...this.drawalList, ...res.data];
        this.isNext = res.next;
      })
    },
    /**
     * @desc 是否需要下拉加载
     */
    searchMore() {
      if (this.isNext) {
        this.getJifenInfo();
        return;
      }
      Toast({
        message: "我是有底线的",
        position: "middle",
        duration: 2000
      });
    }
  },
  components: {
    Scroll,
    Loading,
    Toast,
    MessageBox,
    Indicator
  }
}
</script>

<style lang="scss" scoped>
// *{touch-action: none;}
.record{
  padding-bottom: .8rem;
  li{
    background-color: #fff;
    margin: .3rem;
    margin-bottom: 0;
    overflow: hidden;
    border-radius: .2rem;
    padding: .4rem .3rem;
    .info{
      float: left;
      width: 65%;
      .text{
        font-size: .42rem;
        margin-bottom: .1rem;
      }
      .date{
        color: #999;
      }
    }
    .num{
      float: right;
      width: 35%;
      text-align: right;
      line-height: 1rem;
      font-size: .5rem;
      color: #FE5C83;
    }
  }
}
.scroll {
  height: 100%;
  overflow: hidden;
}

.container {
  position: fixed;
  width: 100%;
  top: 0;
  bottom: 0;
  background: #f0f0f0;
  border-top: 1px solid #e5e5e5;
  ul {
    width: 100%;
    height: auto;
    margin-top: .4rem;
    margin-bottom: .4rem;
    overflow: hidden;
    li.item {
      width: 100%;
      min-height: 70px;
      background: #fff;
      img {
        width: 84px;
        height: 84px;
        display: inline-block;
        margin-left: 10px;
      }
    }
  }
  .pro-info {
    margin-left: 10px;
  }
  .item-count {
    width: 100%;
    height: 25px;
    position: relative;
    margin-top: 5px;
  }

  .hidden {
    display: none;
  }

  .item-count > span {
    font-size: 16px;
    color: rgba(255, 155, 175, 1);
  }
}
.notMore {
  width: 100%;
  height: 100%;
  padding-top: 70px;
  span {
    font-size: 13px;
    color: rgba(160, 154, 155, 1);
    margin-top: 15px;
  }
  img {
    width: 140px;
    height: 85px;
    display: block;
  }

}
</style>
